#include "Objects.h"


/*======|Instantiation|=========*/
BaseCharacter::BaseCharacter()
	:BaseObject(0,0,0,0,true,PLAYER_TYPE)
	,Health(3)
	,CurrentState(IDLE_STATE)
{}
BaseCharacter::BaseCharacter(float x, float y,float t_Health, int t_State, int Type)
	:BaseObject(x,y,0,0,true,Type)
	,Health(t_Health)
	,CurrentState(t_State)
{}

/*======|Update|================*/
bool BaseCharacter::isGoingToCollide(DrawList List, int Direction)
{
	int MyType = this->m_iMyType;

	for each(BaseObject* toCollide in List){
		if(toCollide->m_iMyType != MyType){


			float distancex = fabs(this->m_vPosition.x - toCollide->m_vPosition.x);
			float distancez = fabs(this->m_vPosition.z - toCollide->m_vPosition.z);
			float distance = sqrt((pow(distancex,2)+pow(distancez,2)));
			if(distance < 20)
			{
				float myFront		= this->BoundingRect.front;
				float myBack		= this->BoundingRect.back;
				float myRight		= this->BoundingRect.right;
				float myLeft		= this->BoundingRect.left;

				float theirFront	= toCollide->BoundingRect.front;
				float theirBack		= toCollide->BoundingRect.back;
				float theirRight	= toCollide->BoundingRect.right;
				float theirLeft		= toCollide->BoundingRect.left;

				switch(Direction)
				{
				case DOWN_DIR:
					myFront -= Unit;
					if(myFront < theirBack	&& myFront > theirFront)
					{	
						if(myLeft > theirRight || myRight < theirLeft)
						{return true;}
					}
					break;
				case UP_DIR:
					myFront+= Unit;
					if(myFront < theirBack	&& myFront > theirFront)
					{	
						if(myLeft > theirRight || myRight < theirLeft)
						{return true;}
					}
					break;

				case LEFT_DIR:
				case RIGHT_DIR:

					if(myRight < theirRight || myLeft < theirLeft )
					{
						if(myFront < theirBack	|| myFront > theirFront)
						return true;
					}
					break;


				}
			}
		}
	}
	return false;
}
/*======|Deconstruct|===========*/
BaseCharacter::~BaseCharacter()
{}


